﻿@{
    ViewData["Title"] = "Admin";
}
<div class="row">
    <h2>
        欢迎用户：@ViewData["Userno"]
    </h2>
    <button class="btn" onclick="window.location.href='/Home/Login'">退出</button>
</div>
<div class="container">
    <div class="row">
        <div class="col-md-9">
            <h2>心理测试试卷</h2>
        </div>
        <div class="col-md-3">
            <button class="btn" onclick="window.location.href='/Admin/PaperAdd'">添加试卷</button>
        </div>
    </div>
    <table class="table table-hover">
        <thead>
            <tr>
                <th>id</th>
                <th>测试名称</th>
                <th>测试简述</th>
                <th>添加试题</th>
                <th>修改</th>
                <th>删除</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var Row in ViewBag.Papers.Tables[0].Rows)
            {
                int i = 0;
            <tr>
                @foreach (var Columnin in ViewBag.Papers.Tables[0].Columns)
                {
                    i++;
                    if (i < 4)
                    {
                        <th>@Row[Columnin]</th>
                    }
                }
                <th>
                    <button type="button" class="btn btn-primary" onclick="window.location.href='/Admin/Paper?paperid=@Row[0]'">添加题目</button>
                </th>
                <th>
                    <button type="button" class="btn btn-primary" onclick="window.location.href='/Admin/PaperEdit?paperid=@Row[0]'">修改</button>
                </th>
                <th>
                    <button type="button" class="btn btn-primary" onclick="window.location.href='/Admin/PaperDel?paperid=@Row[0]'">删除</button>
                </th>
            </tr>
            }
        </tbody>
    </table>
</div>
<script>
@*$(document).ready(function () {
    var id = "@ViewData["Userno"]"
    if (id == "") {
        window.location.href = '/';
    };
})*@
</script>
